package com.cutefool.zero.code.admin.meta.column.dto;

import com.cutefool.core.kits.util.Lists;
import com.cutefool.zero.code.admin.meta.column.rules.consts.SerialConsts;
import lombok.Data;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 流水号配置项
 */
@Data
public class SerialOption {

    private Long id;

    private String name;

    private String rule;


    public static void main(String[] args) {
        List<SerialOption> options = Lists.newArrayList();
        SerialOption option = new SerialOption();
        // 文本
        option.setId(1001001L);
        option.setName("文本字符");
        option.setRule("WS");
        options.add(option);

        // 文本
        option.setId(1001002L);
        option.setName("创建时间");
        option.setRule("yyyymmdd");
        options.add(option);
        System.out.println(SerialOption.doGet("demo", options));
    }


    public static String doGet(String model, List<SerialOption> options) {
        return Lists.empty(options).stream()
                .map(e -> SerialConsts.getInvoker(e.id).invoke(model, e)).collect(Collectors.joining());

    }
}
